# Define supported build platforms.
load("//bazel/platforms:platform_util.bzl", "setup_platform")

package(default_visibility = ["//visibility:public"])

constraint_setting(name = "mongo_toolchain")

constraint_value(
    name = "use_mongo_toolchain",
    constraint_setting = ":mongo_toolchain",
)

constraint_setting(name = "distro")

[
    constraint_value(
        name = distro_or_os,
        constraint_setting = ":distro",
    )
    for distro_or_os in [
        "linux",
        "ubuntu18",
        "ubuntu20",
        "ubuntu22",
        "ubuntu24",
        "amazon_linux_2",
        "amazon_linux_2023",
        "debian10",
        "debian12",
        "rhel8",
        "rhel9",
        "suse12",
        "suse15",
    ]
]

[
    setup_platform(arch, distro_or_os, cache_silo)
    for arch in [
        "arm64",
        "amd64",
    ]
    for distro_or_os in [
        "linux",
        "ubuntu18",
        "ubuntu20",
        "ubuntu22",
        "ubuntu24",
        "amazon_linux_2",
        "amazon_linux_2023",
        "debian10",
        "debian12",
        "rhel8",
        "rhel9",
        "suse15",
    ]
    for cache_silo in [
        "",
        "_cache_silo",
    ]
]

constraint_setting(name = "mongo_windows_toolchain_config")

constraint_value(
    name = "use_mongo_windows_toolchain_config",
    constraint_setting = ":mongo_windows_toolchain_config",
)

platform(
    name = "windows_amd64",
    constraint_values = [
        "@platforms//cpu:x86_64",
        "@platforms//os:windows",
    ],
)

platform(
    name = "macos_arm64",
    constraint_values = [
        "@platforms//cpu:arm64",
        "@platforms//os:macos",
    ],
)

platform(
    name = "macos_amd64",
    constraint_values = [
        "@platforms//cpu:x86_64",
        "@platforms//os:macos",
    ],
)

platform(
    name = "linux_ppc64le",
    constraint_values = [
        "@platforms//cpu:ppc",
        "@platforms//os:linux",
    ],
)

platform(
    name = "linux_s390x",
    constraint_values = [
        "@platforms//cpu:s390x",
        "@platforms//os:linux",
    ],
)

platform(
    name = "rhel8_ppc64le",
    constraint_values = [
        "@platforms//cpu:ppc",
        "@platforms//os:linux",
        ":use_mongo_toolchain",
        ":rhel8",
    ],
)

platform(
    name = "rhel9_ppc64le",
    constraint_values = [
        "@platforms//cpu:ppc",
        "@platforms//os:linux",
        ":use_mongo_toolchain",
        ":rhel9",
    ],
)

platform(
    name = "rhel8_s390x",
    constraint_values = [
        "@platforms//cpu:s390x",
        "@platforms//os:linux",
        ":use_mongo_toolchain",
        ":rhel8",
    ],
)

platform(
    name = "rhel9_s390x",
    constraint_values = [
        "@platforms//cpu:s390x",
        "@platforms//os:linux",
        ":use_mongo_toolchain",
        ":rhel9",
    ],
)

py_binary(
    name = "remote_execution_containers_generator",
    srcs = ["remote_execution_containers_generator.py"],
    visibility = ["//visibility:public"],
)

exports_files([
    "remote_execution_containers.bzl",
])
